<?php 
	session_start();
	require('../core/config.php');
	
	if(isset($_POST['username'])){
		if(loginSub($_POST['username'],md5($_POST['password']),1)==true){
			$_SESSION['islogin'] = 1;
			$_SESSION['username'] = $_POST['username'];
		}
	}
	
	if(isset($_SESSION['islogin'])){
		$target = 'default.php';
		if(isset($_GET['action'])){
			switch($_GET['action']){
				case 'article':
					$target = 'article.php?';
					break;
				case 'editor':
					$target = 'editor.php?';
					if(isset($_GET['editor'])){
						$target .= "editor={$_GET['editor']}";
					}
					break;
			}
		}
		$smarty->assign('target',$target);
		$smarty->display($_config['root']."admin/html/index.html");
	}else{
		include('login.php');
	}
?>